package com.stu.exercise.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.stu.exercise.entity.Shopping;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ShopMapper extends BaseMapper<Shopping> {

    @Select("select *, u.name uname from shopping s, user u where s.user_id = u.id and s.name like concat('%', #{name}, '%')")
    List<Shopping> selectShops(String name);

    @Insert("<script>INSERT INTO equipment (name, model, price, stock, description) VALUES <foreach collection='shops' item='shop' separator=','>(#{shop.name}, #{shop.model}, #{shop.price}, #{shop.amount}, #{shop.supplier})</foreach></script>")
    int batchStorage(@Param("shops") List<Shopping> shops);
}
